<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./js/jquery-3.7.1.min.js"></script>
    <style>
        .box{
            height: 100px;
            background-color: red;
            margin: 10px;
        }
        .box1{
            color: blue;
            font-size: 50px
        }
        .slectColor{
            background-color: green;        
        }
    </style>
</head>
<body>
    <div class="box ">111</div>
    <button id="add">add</button>    
    <button id="remove">remove</button>
    <button id="toggle">toggle</button>
</body>
<script>
    //添加类名
    //.addClass()
    $("#add").click(function(){
       $(".box").addClass("box1 box2")
    });
    //删除类名
    //.removeClass()  多个类名用空格隔开
    $("#remove").click(function(){
        $(".box").removeClass("box1 box")
    });
    //切换类名
    //.toggleClass()
    $("#toggle").click(function(){
        $(".box").toggleClass("slectColor")      
    })
</script>
</html>